import threading
import time
mutexA=threading.Lock()
mutexB=threading.Lock()
class Mythread1(threading.Thread):
    def run(self):
        mutexA.acquire()
        print(self.name+'-------do1---up----')
        time.sleep(1)

        #线程二中mutexB锁没有释放
        mutexB.acquire()
        print(self.name,'-----do1----down')
        mutexB.release()

        mutexA.release()


class Mythread2(threading.Thread):
    def run(self):
        mutexB.acquire()
        print(self.name + '-------do1---up----')
        time.sleep(1)

        mutexA.acquire()
        print(self.name, '-----do1----down')
        mutexA.release()

        mutexB.release()

if __name__ == '__main__':
    t1=Mythread1()
    t2=Mythread2()

    t1.start()
    t2.start()